#ifndef API_DATA_H
#define API_DATA_H

#define ARDUINOJSON_ENABLE_STD_STRING 1
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
#include <ArduinoJson.h>
#include <Arduino.h>
#include <vector>
#include "api_data.h"

namespace Api
{

#pragma region HourData

    /* 小时数据 */
    class HourData
    {
    protected:
        int timestamp;
        String str_hour;
        float temp;
        String weather_name;
        String weather_icon;
        float pop;
        int popPercent;

    public:
        HourData();
        void load(int timestamp, float temp, String weather_name, String weather_icon, float pop);
        String getStrHour();
        float getTemp();
        String getWeatherName();
        String getWeatherIcon();
        float getPop();
        int getPopPercent();
    };

#pragma endregion

#pragma region DayData

    /* 天数据 */
    class DayData
    {
    protected:
        int timestamp;
        String strWeek;
        float tempMin;
        float tempMax;
        String weather_name;
        String weather_icon;
        float pop;
        int popPercent;

    public:
        DayData();
        void load(int timestamp, float tempMin, float tempMax, String weather_name, String weather_icon, float pop);
        String getStrWeek();
        float getTempMin();
        float getTempMax();
        String getWeatherName();
        String getWeatherIcon();
        float getPop();
        int getPopPercent();
    };

#pragma endregion

#pragma region TodayData

    /* 今天数据容器 */
    class TodayData
    {
    protected:
        int timestamp;
        String strDay;
        float temp;
        String weather_name;
        String weather_icon;
        float pop;
        int popPercent;
        int pressure;
        int humidity;
        int wind_speed;

    public:
        TodayData();
        void load(int timestamp, float temp, String weather_name, String weather_icon,
                          float pop, int pressure, int humidity, int wind_speed);
        int getTimestamp();
        String getStrDay();
        float getTemp();
        String getWeatherName();
        String getWeatherIcon();
        float getPop();
        int getPopPercent();
        int getPressure();
        int getHumidity();
        int getWindSpeed();
    };

#pragma endregion

#pragma region HardwareData

    class HardwareData
    {
    protected:
        float batteryPercent = NULL;
        float temperature = NULL;
        float humidity = NULL;

    public:
        HardwareData();
        void load(float battery_percent, float temperature, float humidity);
        float getBatteryPercent();
        float getTemperature();
        float getHumidity();
    };

#pragma endregion

#pragma region Data

    /* 标准数据容器 */
    class Data
    {
    protected:
        TodayData todayData;
        HardwareData hardwareData;
        std::vector<HourData> hoursData;
        std::vector<DayData> daysData;

    public:
        Data();
        void loadWeather(DynamicJsonDocument doc);
        void loadHardware(Helper::Hardware hardware);
        TodayData getTodayData();
        HardwareData getHardwareData();
        std::vector<HourData> getHoursData();
        std::vector<DayData> getDaysData();
    };

#pragma endregion

}

#endif